package com.lingnan.wanxiangxinxun.config;


import com.lingnan.wanxiangxinxun.interceptor.LoginCheckInterceptor_admin;
import com.lingnan.wanxiangxinxun.interceptor.LoginCheckInterceptor_client;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration //配置类
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginCheckInterceptor_admin loginCI_AD;
    @Autowired
    private LoginCheckInterceptor_client loginCI_C;

    @Override //注册拦截器
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginCI_AD).addPathPatterns("/admin/**")
           .excludePathPatterns("/admin/employee/signIn",
                                "/admin/common/ParseJwt/**");

        registry.addInterceptor(loginCI_C).addPathPatterns("/user/**")
                .excludePathPatterns("/user/user/signIn/**","/user/user/register/**",
                        "/user/news/**",
                        "/user/news-category/getAll",
                        "/user/notice/getGlobalNotice/**",
                        "/user/user-comment/getAllByNewsId/**",
                        "/user/common/ParseJwt/**");

    }
}
